package de.tu_darmstadt.gdi1.xcom.controller.events;

import de.tu_darmstadt.gdi1.xcom.model.elements.DirectionEnum;

public enum ActionEnum {
	
	Move('m'), RotateLeft('l'), RotateRight('r'), Shoot('s'), Use('u'), Attack('a'), Idle('i'), EndTurn('e');

	private char c;
	
	private ActionEnum(char c){
		this.c = c;
	}
	
	public static ActionEnum getActionFromChar(char c){
		switch(c){
			case 'm': return Move;
			case 'l': return RotateLeft;
			case 'r': return RotateRight;
			case 's': return Shoot;
			case 'u': return Use;
			case 'a': return Attack;
			case 'i': return Idle;
			case 'e': return EndTurn;
		}
		return null;
	}
	public static ActionEnum getMoveAction(DirectionEnum mobDirection, DirectionEnum dir){
	switch(mobDirection){
	case North: switch(dir) {
		case North: return Attack;
		case East: return RotateRight;
		case West: return RotateLeft;
		}
		break;
	case South: switch(dir){
		case South: return Attack;
		case West: return RotateRight;
		case East: return RotateLeft;
		}
		break;
	case West: switch(dir){
		case West: return Attack;
		case North: return RotateRight;
		case South: return RotateLeft;
		}
		break;
	case East: switch(dir){
		case East: return Attack;
		case South: return RotateRight;
		case North: return RotateLeft;
		}
		break;
	}
	return Idle;
}
	
	public char getChar(){
		return c;
	}
}
